<?php
class ExtDirectView extends View {
	private $form = false;
	private $upload = false;
	public function __construct($data = array(), $form = false, $upload = false) {
		parent::__construct ( $data, '' );
		$this->form = $form;
		$this->upload = $upload;
	}
	
	public function render($action, $module) {
		$data = $this->data;
		if ($this->form && $this->upload) {
			return '<html><body><textarea>' . json_encode ( $data ) . '</textarea></body></html>';
		}
		return json_encode ( $data );
	}
	
	public function setHeader() {
		if (isset ( $HTTP_RAW_POST_DATA )) {
			@header ( 'Content-Type: text/javascript' );
		}
	}
}